from threading import Thread

a = 100

def add():
    print('子线程1开始')
    global a
    a = a + 30
    print(f'a: {a}, 子线程1结束')

def sub():
    print('子线程2开始')
    global a
    a = a - 50
    print(f'a: {a}, 子线程2结束')

if __name__ == '__main__':
    print('父进程开始, a:', a)
    add = Thread(target=add)
    sub = Thread(target=sub)
    add.start()
    sub.start()
    add.join()
    sub.join()

    print('最后, a:', a)
    print('主进程结束')
